package com.sky.web.data2.menu.controller;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.sky.web.data2.menu.entity.Menu;
import com.sky.web.data2.menu.service.MenuService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;


@RestController
@Api(description = "data2-菜单")
public class MenuController {
	@Resource
	private MenuService menuService;
	
	@ApiOperation(value = "获取菜单列表")
	@ApiImplicitParams({
		@ApiImplicitParam(name = "id" , value = "id" , paramType = "query" , required = false ),
		@ApiImplicitParam(name = "name" , value = "name" , paramType = "query" , required = false )
	})
	@RequestMapping(value="/getMenus", method = RequestMethod.GET)
	public List<Menu> getMenus(Menu menu) {
		return menuService.getMenus(menu);
	}
	
	@ApiOperation(value = "添加菜单")
	@ApiImplicitParams({
		@ApiImplicitParam(name = "id" , value = "id" , paramType = "query" , required = true ),
		@ApiImplicitParam(name = "name" , value = "name" , paramType = "query" , required = true ),
		@ApiImplicitParam(name = "url" , value = "url" , paramType = "query" , required = true )
	})
	@RequestMapping(value="/addMenu", method = RequestMethod.POST)
	public String addMenu(Menu menu){
		menuService.addMenu(menu);
		return "success";
	}
}
